<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../include/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>餐厅管理员餐厅设置</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<%@ include file="../include/jsCss.jsp"%>

  </head>
  
  <body>
  		<form action="user/restaurent-user!userAddRoleSave.html" method="post" id="userForm">
      	  <table border="1">
      	  	 <tr>
      	  		<td>用户名</td>
      	  		<td>
      	  			<input type="hidden" name="userDto.userId"  value="${restaurentUserDto.id}"/>
      	  			${restaurentUserDto.name}
      	  		</td>
      	  	 </tr>
      	  	 <tr>
      	  	 	<td>角色</td>
      	  	 	<td>
      	  	 		<input type="hidden" name="roleIds" id="roleIds"/>
					<s:iterator value="selectRoleList">  
						<input type="checkbox" name="roleName" value="${roleId}" <s:if test="selectStatus == true">checked="checked"</s:if>/> ${roleName }&nbsp;&nbsp;
					</s:iterator>
				</td>
      	  	 </tr>
      	  	 <tr>
      	  	 	<td colspan="2" style="text-align: center;"> 
      	  	 		<input type="button" value="保存" onclick="submitUserAddRole()">
      	  	 	</td>
      	  	 </tr>
      	  </table>
      </form>
      
      <script>
      		function reset() {
      			$("#roleIds").val("");
      		}
      		function submitUserAddRole() { 
      			$("#roleIds").val(""); 
      			var roleId = "";
      			$("input[name='roleName']").each(function(i, v){
      				if (v.checked == true) {
      					 roleId = $("#roleIds").val() + v.value + ",";
      				}
      				$("#roleIds").val(roleId); 
      			});
      			
      			$("#userForm").submit();
      		}
      		function addRoleId(t) { 
      			var roleId = "";
      			if (t.checked) {
      			  roleId = $("#roleIds").val() + t.value + ",";
      			} else {
      			  roleId =$("#roleIds").val().replace(t.value+",", "");
      			}
      			$("#roleIds").val(roleId);
      		} 
      </script>
  </body>
</html>
